import { citys } from './city.js';
Page({

  data: {
    windowHeight: 100,
    addressObj: {
      name: '',
      address: '',
      tel: '',

    },
    isShowRegion: false,
    defaultcityData: [{ code: '320000' }, { code: '321200' }, { code: '321282' }],
    cityData: citys,
    citySelectShow:'',
    picker_08_data: [],
    picker_08_index:[],
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    //设置scroll-view高度
    wx.getSystemInfo({
      success: function (res) {
        that.setData({ windowHeight: res.windowHeight - 90 });
      }
    });
    // 设置默认省市区
    setTimeout(() => {
      this.setData({
        defaultcityData: [
          { code: '320000' }, { code: '321200' }, { code: '321282' }
        ]
      })
    }, 1000)
  },



  showPicker: function () {
    this.setData({
      isShowRegion: true
    })
  },
  sureCallBack(e) {
    this.setData({
      isShowRegion: false,
      picker_08_data: JSON.stringify(e.detail.choosedData),
      picker_08_index: JSON.stringify(e.detail.choosedIndexArr)
    })
    console.log(e.detail.choosedData)
    var citySelectedArr = e.detail.choosedData;
    var cityStr = citySelectedArr[0].name + ' ' + citySelectedArr[1].name + ' ' + citySelectedArr[2].name; 
    this.setData({
      citySelectShow: cityStr
    })
  },
  cancleCallBack() {
    this.setData({
      isShowRegion: false,})
  },
})
